package com.code.zg.news.app;

import android.app.Application;
import android.support.v7.appcompat.BuildConfig;

import com.code.zg.news.di.component.AppComponent;
import com.code.zg.news.di.component.DaggerAppComponent;
import com.code.zg.news.di.module.AppModule;
import com.orhanobut.logger.LogLevel;
import com.orhanobut.logger.Logger;

/**
 * Created by zhanggang on 2017/2/22.
 */

public class App extends Application {
    private static App instance;
    private static AppComponent appComponent;

    public static App getInstance(){
        return instance;
    }
    @Override
    public void onCreate() {
        super.onCreate();
        instance=this;
        initLibs();

    }

    private void initLibs() {
        Logger.init("xx")
                .logLevel(BuildConfig.DEBUG? LogLevel.FULL:LogLevel.NONE)
                .methodCount(2);
//        LeakCanary.install(this);
//        BlockCanary.install(this, new MyBlockCanaryContext()).start();
    }
    //获取appComponent
    public static AppComponent getAppComponent(){
        appComponent = DaggerAppComponent
                .builder()
                .appModule(new AppModule(instance))
                .build();
        return appComponent;
    }
}
